<div class="tab_item" style="display:block;">
    <div class="ui_table">
        <form method="post">
            <input type="hidden" name="id" value="${entity.id}">
            <input type="hidden" name="portrait" id="portrait_${pid}" value="${(entity.portrait)!''}">
            <fieldset>
                <legend>基本信息</legend>
                <div class="ui_table">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="70" align="right">姓名：</td>
                            <td><input type="text" class="text easyui-validatebox" name="realName" required="true"
                                       maxlength="20" value="${(entity.realName)!''}"/></td>
                            <td width="70" align="right" valign="top" rowspan="2" style="padding-top:10px;">头像：</td>
                            <td rowspan="2">
                                <div class="portrait">
                                    <a href="javascript:void(0)"><img id="image_${pid}"
                                                                      src="<#if entity.portrait?? && entity.portrait?length gt 0>${(controller.appConfig.staticUrl)!''}${entity.portrait}<#else>${app.imagePath}/user.jpg</#if>"/><span>修改头像</span></a>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td width="70" align="right">昵称：</td>
                            <td><input type="text" class="text easyui-validatebox" name="nickname" maxlength="40"
                                       value="${(entity.nickname)!''}"/></td>
                        </tr>

                        <tr>
                            <td width="70" align="right">手机号码：</td>
                            <td><input type="text"
                                       class="text easyui-validatebox"
                                       required="true"
                                       name="mobile"  maxlength="11"
                                       validType="mobileunique[${entity.id}]"
                                       value="${(entity.mobile)!''}"/>
                            </td>
                            <td align="right">邮件：</td>
                            <td><input type="text" class="text easyui-validatebox" name="mail" maxlength="20"
                                       value="${(entity.mail)!''}"/></td>

                        </tr>
                        <tr>
                            <td align="right">密码：</td>
                            <td><input type="password" class="text easyui-numberbox" name="password" maxlength="40"
                                       validType="equals['#password2_${pid}']"
                                       id="password1_${pid}"/></td>
                            <td align="right">确认密码：</td>
                            <td><input type="password" class="text easyui-numberbox" name="password2" maxlength="40"
                                       validType="equals['#password1_${pid}']"id="password2_${pid}"/></td>
                        </tr>
                        <tr>
                            <td align="right">启用：</td>
                            <td>
                                <span class="radio_box">
                                    <input type="radio" class="radio" name="activeFlag" id="active_flag_1"
                                           <#if entity.activeFlag?? && entity.activeFlag == 1>checked</#if>
                                           value="1"/><label for="active_flag_1">启用</label>
                                </span>
                                <span class="radio_box">
                                    <input type="radio" class="radio" name="activeFlag" id="active_flag_0"
                                           <#if entity.activeFlag?? && entity.activeFlag == 1><#else>checked</#if>
                                           value="0"/><label for="active_flag_0">禁用</label>
                                </span>
                            </td>
                            <td align="right">性别：</td>
                            <td>
                                <span class="radio_box">
                                    <input type="radio" class="radio" name="gender" id="sex_1"
                                           <#if entity.gender?? && entity.gender == 1>checked</#if> value="1"/><label
                                        for="sex_1">男</label>
                                </span>
                                <span class="radio_box">
                                    <input type="radio" class="radio" name="gender" id="sex_2"
                                           <#if entity.gender?? && entity.gender == 1><#else>checked</#if>
                                           value="2"/><label for="sex_2">女</label>
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">身份证号：</td>
                            <td><input type="text" class="text easyui-validatebox" maxlength="20"
                                       name="idNo" validType="idnounique[${entity.id}]" required
                                       value="${(entity.idNo)!''}"/>
                            </td>
                            <td align="right">绑定卡号：</td>
                            <td><input type="text" class="text easyui-validatebox"maxlength="20"
                                       name="cardNo" validType="cardnounique[${entity.id}]"
                                       value="${(entity.cardNo)!''}"/></td>
                        </tr>

                        <#--新增：运营商代理商栏目-->
                        <#--如果是总部登录    <#if !entity.supplierId??||entity.supplierId==0>-->
                         <#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_PLATFORM'].value>
                            <td align="right">运营商：</td>
                            <td>
                                <input name="agentId" class="easyui-combotree" editable="false"
                                       style="width: 184px; height: 28px;" value="${(entity.agentId)!''}"
                                       data-options="url:'${contextPath}/security/basic/agent/tree.htm?',method:'get',onSelect: function(rec){
                                       var url = '${contextPath}/security/hdw/agency/tree.htm?agentId='+rec.id;
                                       $('#agency_id_${pid}').combotree('reload', url);},
                                       onChange:function(){
                                        $('#agency_id_${pid}').combotree('clear');
                                        }
                                        "/>
                            </td>
                                    <#--如果是运营商或者代理商登录 就隐藏-->
                                 <#elseif Session['SESSION_KEY_USER'].type == Session['USER_TYPE_AGENCY'].value||Session['SESSION_KEY_USER'].type == Session['USER_TYPE_AGENT'].value>
                                 <#--隐藏-->
                            <input type="hidden" name="agentId" value="${Session['SESSION_KEY_USER'].agentId}">
                                 </#if>
                        <#--如果是总部或者运营商登录-->
                        <#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_PLATFORM'].value||Session['SESSION_KEY_USER'].type == Session['USER_TYPE_AGENT'].value>
                            <td align="right">代理商：</td>
                            <td>
                                <input name="agencyId" class="easyui-combotree" editable="false"
                                       style="width: 184px; height: 28px;" id="agency_id_${pid}" value="${(entity.agencyId)!''}"
                                       data-options="<#if Session['SESSION_KEY_USER'].agentId??&&Session['SESSION_KEY_USER'].agentId!=0>url:'${contextPath}/security/hdw/agency/tree.htm?agentId=${Session['SESSION_KEY_USER'].agentId}',</#if>method:'get'"
                                       />
                            </td>
                        <#--如果是运营商或者代理商登录就 隐藏-->
                        <#elseif Session['SESSION_KEY_USER'].type == Session['USER_TYPE_AGENCY'].value>
                            <input type="hidden" name="agencyId" value="${Session['SESSION_KEY_USER'].agencyId}">
                        </#if>


                    </table>
                </div>
            </fieldset>
        </form>
    </div>
</div>
<script>

    function set_portrait(param) {
        $('#image_${pid}').attr('src', '${(controller.appConfig.staticUrl)!''}' + param.filePath);
        $('#portrait_${pid}').val(param.filePath);
        $('#' + param.pid).window('close');
    }
    (function () {
        var pid = '${pid}',
                win = $('#${pid}'),
                jform = win.find('form'),
                form = jform[0];

        $("#modules_${pid}").combobox({
            multiple: true,
            editable: false,
            panelHeight: 'auto'
        });
        if ("${(entity.modules)!''}" != '') {
            $("#modules_${pid}").combobox('setValues', "${(entity.modules)!''}".split(","));
        }


        win.find('.portrait').click(function () {
            App.dialog.show({
                css: 'width:558px;height:150px;overflow:visible;',
                title: '上传头像',
                href: "${contextPath}/security/basic/passport/portrait.htm",
                event: {
                    onClose: function () {
                    }
                }
            });
        });


        var snapshot = $.toJSON({
            id: '${entity.id}',
            <#--新增：更新两个属性-->
            agentId:'${(entity.agentId)!''}',
            agencyId:'${(entity.agencyId)!''}',

            nickname: '${(entity.nickname)!''}',
            realName: '${(entity.realName)!''}',
            portrait: '${(entity.portrait)!''}',
            activeFlag: <#if (entity.activeFlag)?? && entity.activeFlag == 1>1<#else>0</#if>,
            mail: '${(entity.mail)!''}',
            gender: ${(entity.gender)!''},
            mobile: '${(entity.mobile)!''}',
            idNo: '${(entity.idNo)!''}',
            cardNo: '${(entity.cardNo)!''}',
            password: ''
        });

        var ok = function () {
            if (!jform.form('validate')) {
                return false;
            }
            var success = true;
            var values = {
                id: '${entity.id}',
                <#--新增：更新2个属性-->
                agentId: form.agentId.value,
                agencyId: form.agencyId.value,

                nickname: form.nickname.value,
                realName: form.realName.value,
                portrait: form.portrait.value,
                activeFlag: $('#active_flag_1').attr('checked') ? 1 : 0,
                mail: form.mail.value,
                gender: $('#sex_1').attr('checked') ? 1 : 2,
                mobile: form.mobile.value,
                idNo: form.idNo.value,
                cardNo: form.cardNo.value,
                password: form.password.value
            };

            if (snapshot != $.toJSON(values)) {
                $.ajax({
                    cache: false,
                    async: false,
                    type: 'POST',
                    url: '${contextPath}/security/basic/passport/update_basic_info.htm',
                    dataType: 'json',
                    data: values,
                    success: function (json) {
                    <@app.json_jump/>
                        if (json.success) {
                        } else {
                            $.messager.alert('提示信息', json.message, 'info');
                            success = false;
                        }
                    }
                });
            }

            return success;
        }

        win.data('ok', ok);

    })();
</script>
